
#include <stdio.h>

// 共用体 更符合本质
struct Staff
{
    char name [30];
    char job;
    union
    {
        int grade;
        char position[50];
    }gOrp;
};

int main()
{
    struct Staff s[2];
    for(int i = 0; i < 2; i++)
    {
        printf("name:");
        scanf("%s",s[i].name);
        getchar();
        printf("job:");
        scanf("%c",&(s[i].job));
        if(s[i].job == 't')
        {
            printf("position:");
            scanf("%s",s[i].gOrp.position);
        }
        else
        {
            printf("grade:");
            scanf("%d",&s[i].gOrp.grade);
        }
    }

    for(int i = 0; i < 2; i++)
    {
        printf("name:%s\n",s[i].name);
        if(s[i].job == 't')
        {
            printf("job:%s\n",s[i].gOrp.position);
        }
        else
        {
            printf("job:%d\n",s[i].gOrp.grade);
        }
    return 0;
    }
}
